<?php
/**
 * the include filter adds the <dig:include /> tag to the page
 *
 * this tag incudes another script
 * you have two options:
 *
 * if you set the src attribute the filter will map the src to an item in the tree
 *
 * if you set the module, controller, and action attributes the filter will run the view action helper
 * which is passes all of the include tag's attributes as well as the current item
 *
 */
class DigCms_View_Filter_Include extends DigCms_View_Filter_ContentFilter
{
    public $tag = 'include';

    protected function _callback($matches)
    {
        $attr = $this->getAttributes($matches[0]);
        if (is_array($attr)) {
            if(isset($attr['src'])) {
                // render the item
                return $this->view->digCmsRenderItem($attr['src']);
            } else {
                // run this as an action
                $attr['item'] = $this->view->item;
                return $this->view->action($attr['action'], $attr['controller'],$attr['module'], $attr);
            }            
        }
        return null;
    }

}
?>
